import torch
import torch_npu

# 检查 NPU 是否可用
if torch.npu.is_available():
    print("NPU is available.")
    device = torch.device('npu')
    tensor = torch.tensor([1.0, 2.0, 3.0], device=device)
    print(tensor)
else:
    print("NPU is not available.")
